load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

test_suite(
    name = "x_defs",
)

go_test(
    name = "foo_test",
    srcs = ["foo_test.go"],
    embed = [":foo"],
    importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/foo",
    pure = "on",
    deps = [":bar"],
)

go_library(
    name = "bar",
    srcs = ["bar.go"],
    importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/bar",
    visibility = ["//visibility:public"],
    x_defs = {"Bar": "Bar"},
    deps = [
        ":baz",
        ":foo",
    ],
)

go_library(
    name = "baz",
    srcs = ["baz.go"],
    importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/baz",
    visibility = ["//visibility:public"],
    x_defs = {"Baz": "Baz"},
    deps = [":qux"],
)

go_library(
    name = "foo",
    srcs = ["foo.go"],
    importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/foo",
    visibility = ["//visibility:public"],
)

go_library(
    name = "qux",
    srcs = ["qux.go"],
    importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/qux",
    visibility = ["//visibility:public"],
    x_defs = {"Qux": "Qux"},
)

genrule(
    name = "data_dep",
    outs = ["data_dep.txt"],
    cmd = "touch $@",
)

go_library(
    name = "x_defs_lib",
    srcs = ["x_defs_lib.go"],
    data = [
        "data_dep.txt",
        "x_defs_lib.go",
    ],
    importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/x_defs_lib",
    x_defs = {
        "LibGo": "$(rlocationpath x_defs_lib.go)",
        "DataDep": "$(rlocationpath :data_dep.txt)",
    },
)

go_test(
    name = "x_defs_test",
    srcs = ["x_defs_test.go"],
    data = [
        "data_dep.txt",
        "x_defs_test.go",
    ],
    x_defs = {
        "BinGo": "$(rlocationpath x_defs_test.go)",
        "DataDep": "$(rlocationpath :data_dep.txt)",
    },
    deps = [
        ":x_defs_lib",
        "//go/runfiles",
    ],
)
